package com.xuecheng.teaching.controller;

import cn.hutool.core.util.StrUtil;
import com.xuecheng.commons.model.dto.CommentStatusDto;
import com.xuecheng.commons.model.dto.CourseCommentDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.CommentReplyVo;
import com.xuecheng.commons.model.vo.PageResponseResult;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.model.vo.StarRankVo;
import com.xuecheng.teaching.job.CommentJob;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.teaching.service.CourseCommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class CourseCommentController {

    @Autowired
    private CourseCommentService  courseCommentService;

    //@Autowired
    //private CommentJob commentJob;

    //门户详情页----评论课程
    @PostMapping("/course-comment")
    public ResponseResult courseComment(@RequestBody CourseCommentDto dto){
        //调用service
        return courseCommentService.courseComment(dto);
    }

    //门户详情页----课程评论列表
    /*
        Request URL: http://www.xuecheng.com/api/teaching/course-comment/for-course?pageNo=1&pageSize=10
        Request Method: POST
     */
    @PostMapping("/course-comment/for-course")
    public ResponseResult pageCourseComment(PageRequest request, @RequestBody CommentStatusDto dto){
        ////为定时调度赋值
        //commentJob.setPageRequest(request);
        //commentJob.setDto(dto);
        ////调用service
        //return commentJob.getResponseResult();
        return courseCommentService.pageCourseComment(request,dto);
    }

    //门户详情页----课程评论统计
    @GetMapping("/course-comment/course-statistics/{targetId}")
    public ResponseResult countCourseComment(@PathVariable("targetId") Integer targetId){
        //调用service
        return courseCommentService.countCourseComment(targetId);
    }

    //教育机构---评论列表
    @PostMapping("/course-comment/list")
    public ResponseResult pageCommentMange(PageRequest request, @RequestBody CommentStatusDto dto){
        //调用service
        return courseCommentService.pageCourseComment(request,dto);
    }

    //评论信息模糊查询
    @GetMapping("/searchByContentName")
    public ResponseResult pageByName(String courseName){
        //调用service
        return courseCommentService.pageByName(courseName);
    }



}
